import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("text"),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center, // 居中
            children: <Widget>[
              Text(
                "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                "aaaaa",
                textAlign: TextAlign.left,
                style: TextStyle(
                    fontSize: 30,
                    color: Color(0xff002050),
                    decoration: TextDecoration.lineThrough, // 中间线穿过去
                    decorationStyle: TextDecorationStyle.wavy // 波浪线 dot虚线
                    ),
                overflow: TextOverflow.ellipsis,
                // 超出部分省略号表示
//                overflow: TextOverflow.clip, // 超出部分截断
                maxLines: 2,
                // 最大行数
                softWrap: true, // 自动换行
              ),
              SizedBox(
                height: 10,
              ),
              Text.rich(
                TextSpan(
                  children: [
                    TextSpan(text: "home:"),
                    TextSpan(
                        text: "https://flutterchina.club", style: TextStyle(color: Colors.blue)),
                    WidgetSpan(child: Icon(Icons.home))
                  ],
                ),
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
              ),
              RichText(
                text: TextSpan(
                    text: "11111111",
                    style: TextStyle(color: Color(0xff123456), fontSize: 20),
                    children: <TextSpan>[
                      TextSpan(
                          text: "2222222",
                          style: TextStyle(color: Color(0xff127756), fontSize: 15)),
                      TextSpan(
                          text: "dsfdsfsd",
                          style: TextStyle(color: Color(0xff127326), fontSize: 18)),
                      TextSpan(
                          text: "點我試試",
                          style: TextStyle(color: Color(0xff127996), fontSize: 25),
                          recognizer: TapGestureRecognizer()
                            ..onTap = () async {
                              String url = "http://www.baidu.com";
                              if (await canLaunch(url)) {
                                await launch(url);
                              } else {
                                throw 'page not found';
                              }
                            }),
                    ]),
              )
            ],
          ),
        ),
      ),
    );
  }
}
